// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  const desc = event.desc
  const imgs = event.imgs
  const curSortId = event.sortId
  const addPicResult = await db.collection("pic").add({
    data:{
      desc:desc,
      imgs:imgs,
      sortId: curSortId,
      ctime:new Date()
    }
  })
   // console.log("addPicResult==" + JSON.stringify(addPicResult))
  if (addPicResult.errMsg=="collection.add:ok"){
    return {
      code:0
    }
  }else{
    return {
      code:-1,
      msg: addPicResult.errMsg
    }
  }
}